/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sessionFacades;

import businessObjects.Formulario;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import services.FormularioServicesLocal;

/**
 *
 * @author williamprado
 */
@Stateless
public class FormularioFacade implements FormularioFacadeRemote {
    /*@PersistenceContext(unitName = "Adz-ejbPU")
    private EntityManager em;*/

    @EJB
    private FormularioServicesLocal formServices;

    public void guardarFormulario(Formulario form) {
            formServices.nuevoFormulario(form);
    }

    public void actualizarFormulario(Formulario form) {
            formServices.actualizarFormulario(form);
    }

    public void eliminarFormulario(int id) {
            formServices.eliminarFormulario(id);
    }

    public Formulario consultarFormulario(int id) {
        Formulario form = formServices.consultarFormulario(id);
        return form;
    }

    public List<Formulario> consultarFormulariosPauta(int idPauta) {
        List<Formulario> lf = formServices.consultarFormulariosPauta(idPauta);
        return lf;
    }




    /*public void create(Formulario formulario) {
        em.persist(formulario);
    }

    public void edit(Formulario formulario) {
        em.merge(formulario);
    }

    public void remove(Formulario formulario) {
        em.remove(em.merge(formulario));
    }

    public Formulario find(Object id) {
        return em.find(Formulario.class, id);
    }

    public List<Formulario> findAll() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Formulario.class));
        return em.createQuery(cq).getResultList();
    }

    public List<Formulario> findRange(int[] range) {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        cq.select(cq.from(Formulario.class));
        Query q = em.createQuery(cq);
        q.setMaxResults(range[1] - range[0]);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }

    public int count() {
        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root<Formulario> rt = cq.from(Formulario.class);
        cq.select(em.getCriteriaBuilder().count(rt));
        Query q = em.createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }*/

}
